<!doctype html>
<html>
<head>
	<#include "/pay/include/head_view.html" />
	<style>


	</style>
</head>

<body>

<div class="user_in" id="app">
	<i-form ref="myForm" :model="myform" :rules="ruleValidate" :label-width="10">
		<table id="sample-table-1" class="table table-striped table-bordered table-hover">
			<tbody>
			<tr height="35px">
				<td width="15%">
					商户uid:
				</td>
				<td width="35%">
					{{myform.uuid}}
				</td>
				<td width="15%">
					商户账号:
				</td>
				<td width="35%">
					{{myform.useracc}}
				</td>
			</tr>
			<tr>
				<td>
					商户sign_key:
				</td>
				<td>
					{{bus.signKey}}
					<i-button type="info" icon="shuffle" @click="reSetSignKey"> 重置 </i-button>
				</td>
				<td>
					商户名称:
				</td>
				<td>
					{{myform.nikename}}
				</td>
			</tr>
			<tr>
				<td>
					回调地址:
				</td>
				<td colspan=3>
					{{myform.notifyUrl}}
				</td>

			</tr>
			<tr>

				<td>
					跳转地址:
				</td>
				<td colspan=3>
					{{myform.gobackUrl}}
				</td>
			</tr>


			<tr>
				<td>
					email地址:
				</td>
				<td>
					{{myform.email}}
				</td>
				<td>
					QQ号码:
				</td>
				<td>
					{{myform.qq}}
				</td>
			</tr>

			<tr>
				<td>
					当前套餐:
				</td>
				<td>
					<font color="red">{{bus.busTypeStr}}</font>
				</td>
				<td>
					套餐有效期:
				</td>
				<td>
					<font color="red">{{bus.busValidity}}</font>

				</td>
			</tr>
			<tr>
				<td>
					账户余额:
				</td>
				<td>
					<font color="red">{{bus.eMoney}} 元</font>

					<i-button type="error" icon="social-usd-outline" @click="recharge" long> 充 值 </i-button>
				</td>
				<td>
					套餐自动续费:
				</td>
				<td>
					{{bus.autoReFeeStr}}
				</td>
			</tr>

			</tbody>
		</table>



</div>


</body>

	<script>
        var urls = {
            query:'/api/sys/sysuser/queryCurrUser'
            ,querybus:'/api/pay/paybus/queryCurrBus'
            ,reSetSignKey:'/api/pay/paybus/reSetSignKey'
            ,save:'/api/sys/sysuser/saveCurrUser'
        };

        var vm = new Vue({
            el: '#app',
            data:{
				myform: {
					isState:true,
					state: 1,
					restype:1,
					id:null,//主键
					test:""
				},
                bus: {
                    isState:true,
                    state: 1
                },
				ruleValidate: {
					email: [
						{ required: true, message: '请输入邮箱地址', trigger: 'blur' },
						{ type: 'email', message: '邮箱地址格式不对', trigger: 'blur' }
					],
					qq: [
						{ required: false, message: '请输入QQ号码', trigger: 'blur' },
						{ type: 'string', message: 'QQ号码格式不对', trigger: 'blur',pattern: /^[0-9]+$/ }
					],
					notifyUrl: [
						{ required: true, message: '请输入回调地址', trigger: 'blur' },
						{ type: 'url', message: '回调地址必须是http://格式的地址', trigger: 'blur' }
					],
					gobackUrl: [
						{ required: true, message: '请输入跳转地址', trigger: 'blur' },
						{ type: 'url', message: '跳转地址必须是http://格式的地址', trigger: 'blur' }
					]
				}
            },
            created:function(){
                this.loadData();
            },
            methods: {
                loadData:function(){
                    $.ajax(
                        {
                            type: 'post', // 提交方式 get/post
                            url:urls.query, // 需要提交的 u
                            async:true,
                            cache:false,
                            dataType:'json',
                            success: function(ret){
                                if(ret.success){
                                    vm.myform = ret.data;
                                    vm.loadBus();
                                }else{
                                    layer.alert("您还没登录，或登录超时，请重新登录");
                                    window.top.location.href="/pay/login.html";
                                }
                            },
                            error:function(){
                                layer.alert("系统错误，请稍候再试");
                            }
                        });
                },
                loadBus:function(){
                    $.ajax(
                        {
                            type: 'post', // 提交方式 get/post
                            url:urls.querybus, // 需要提交的 u
                            async:true,
                            cache:false,
                            dataType:'json',
                            success: function(ret){
                                if(ret.success){
                                    vm.bus = ret.data;
                                    vm.bus.autoReFee=vm.bus.autoReFee+'';
                                    vm.bus.payTimeOut=vm.bus.payTimeOut+'';
                                    vm.myform.notifyUrl=vm.bus.notifyUrl;
                                    vm.myform.gobackUrl=vm.bus.gobackUrl;
                                    vm.myform.signKey=vm.bus.signKey;
                                }
                            },
                            error:function(){
                                layer.alert("系统错误，请稍候再试");
                            }
                        });
                },
                reSetSignKey:function(){
                    layer.confirm('重置将会使得之前的sign_key马上失效，确认需要进行重置么?', function(){
                        $.ajax(
                            {
                                type: 'post', // 提交方式 get/post
                                url:urls.reSetSignKey, // 需要提交的 u
                                async:true,
                                cache:false,
                                dataType:'json',
                                success: function(ret){
                                    if(ret.success){
                                        vm.bus.signKey = ret.data;
                                    }
                                },
                                error:function(){
                                    layer.alert("系统错误，请稍候再试");
                                }
                            });
                        layer.closeAll('dialog');
                    });
                },
                recharge:function(){
                    window.top.location.href="/pay/recharge.html";
                },
                save:function(){
                    var valid = this.$refs['myForm'].validate();
                    //alert(valid);
                    PB.ajax({url:urls.save,data:this.myform}, function (d) {
                        PB.alert('保存成功!','success');
                    });
                }
            }
        });




	</script>
<#include "/pay/include/hmt.html" />
</html>
